package com.eling.elcms.community.service.impl;

import com.eling.elcms.community.dao.ICommunityDao;
import com.eling.elcms.community.event.CommunityAddEvent;
import com.eling.elcms.community.model.Community;
import com.eling.elcms.community.service.ICommunityManager;
import com.eling.elcms.core.event.EventEngine;
import com.eling.elcms.core.service.impl.GenericManagerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CommunityManagerImpl extends GenericManagerImpl<Community, Long> implements ICommunityManager {
    @Autowired
    public void setCommunityDao(ICommunityDao dao) {
        this.dao = dao;
    }
    
    
	
    @Override
    public Community save(Community object) {
    	Community community = super.save(object);

    	//主服务器社区新增监听 推送到对应社区服务器
    	CommunityAddEvent addEvent = new CommunityAddEvent();
    	addEvent.setCommunity(community);
    	EventEngine.dispatch(addEvent);

    	
    	return community;
    }
    
}
